﻿using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;
using System.Reflection;

namespace VsPackageCommon
{
    public static class CatalogBuilder
    {

        public static ComposablePartCatalog GetCatalog()
        {
            var callingAssembly = Assembly.GetCallingAssembly();
            var commonAssembly = typeof(CatalogBuilder).Assembly;
            if (commonAssembly == callingAssembly)
            {
                return new AssemblyCatalog(callingAssembly);
            }
            return new AggregateCatalog(new AssemblyCatalog(callingAssembly), new AssemblyCatalog(commonAssembly));
        }
    }
}